/* @(#)GSOperatorModAction.java   
 *
 * Project: GS
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   Jenny Li    2006-3-10     新增
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.action;

import java.util.ArrayList;
import java.util.HashMap;

import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.bean.GSOrganizationBean;
import com.hitrust.gs.business.GSOrganizationProcessor;
import com.hitrust.gs.dao.GSOperatorDAO;
import com.hitrust.gs.dao.GSOrganizationDAO;
import com.hitrust.gs.form.GSOperatorScanQueryForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;

/**
 * 
 */
public class GSOperatorModAction extends GSBaseAction {

    
    public String execute(GSBaseForm aForm) throws Exception {
        
        GSOperatorScanQueryForm tForm = (GSOperatorScanQueryForm)aForm;
        String tOperId = tForm.getOperId2();
        GSOperatorDAO tOperDAO = new GSOperatorDAO();
        //查询要修改的操作员是否存在
        GSOperatorBean tOperBean = tOperDAO.queryOperById(tOperId);
        if(tOperBean == null){
            GSLogWriter.error(this,GSException.E10034_MSG);
            throw new GSException(GSException.E10034,GSException.E10034_MSG);
        }else{
            tForm.getRequest().setAttribute("GSOperatorBean",tOperBean);
            
            GSOrganizationDAO tOrgDAO = new GSOrganizationDAO();
            GSOrganizationBean tUpperOrgBean = tOrgDAO.queryUpperOrg(tOperBean.getGs_oper_org_id());
            tForm.getRequest().setAttribute("UpperOrganization",tUpperOrgBean);
            
        }
        //取得上级组织机构编号
        ArrayList tUpperOrg=GSOrganizationProcessor.queryManageUpOrg();
        aForm.getRequest().setAttribute("Oraganization",tUpperOrg);
        
        //取得所有组织机构编号
        ArrayList tAllOraganization = GSOrganizationProcessor.queryManageOrg("","");

        GSOrganizationProcessor tOrgProc = new GSOrganizationProcessor();
        //封装一级组织机构对应二级组织，传给页面用于显示部门下拉列表
        HashMap tMap = tOrgProc.getOrgAndSubOrg(tUpperOrg,tAllOraganization);
        aForm.getRequest().setAttribute("Organization2",tMap);
        aForm.getRequest().setAttribute("querymode","Q");            
        return GSBaseConstants.FORWARD_SUCCESS;
    }

}
